<?php

class CustomValidatorFile extends sfValidatorFile {

    protected function configure($options = array(), $messages = array()) {
        parent::configure($options, $messages);

        // redefine the mime_categories option
        $this->setOption('mime_categories', array(
            'images' => array(
                'image/jpeg',
                'image/pjpeg',
                'image/png',
                'image/x-png',
            ))
        );

        $mime_types = isset($options['mime_types']) ? $options['mime_types'] : '';
        $this->setOption('max_size', sfConfig::get('app_upload_max_size_' . $mime_types));

        $this->addOption('temp');
        $temp = isset($options['temp']) ? $options['temp'] : true;

        if ($temp) {
            $this->setOption('path', sfConfig::get('sf_upload_dir') . '/temp');
        } else {
            $this->setOption('path', sfConfig::get('sf_upload_dir') . '/' . $mime_types);
        }
    }

}
